const express = require("express")
const classRouter = express.Router()

const classSevr = require("../../services/classServices")



classRouter.get("/init", async(req,res,next)=>{
    try {
        const result = await classSevr.getClass()
        if(result){
            res.send(result)
        }
    } catch (error) {
        next(error)
    }
})

classRouter.get("/classify", async(req,res,next)=>{
    try {
        const result = await classSevr.getclassify(req.query)
        if(result){
            res.send(result)
        }
    } catch (error) {
        next(error)
    }
})

classRouter.get("/Statistics", async(req,res,next)=>{
    try {
        const result = await classSevr.Statistics()
        if(result){
            res.send(result)
        }
    } catch (error) {
        next(error)
    }
})

classRouter.get("/addClass", async(req,res,next)=>{
    try {
        const result = await classSevr.addClass(req.query.classText)
        if(result){
            res.send(result)
        }
    } catch (error) {
        next(error)
    }
})

module.exports = classRouter